package com.example.demo.controller;

import org.springframework.jms.core.JmsMessagingTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.jms.Queue;

/**
 * Created by hongzhenyue on 18/2/26.
 */
@Controller
@ResponseBody
public class QueueController {
    @Resource
    private JmsMessagingTemplate jmsMessagingTemplate;

    @Resource
    private Queue queue;

    /**
     * 消息生产者
     */
    @RequestMapping("/send")
    public void send(){
        this.jmsMessagingTemplate.convertAndSend(this.queue,"发送消息");
    }
}
